﻿using System;
using System.Collections.Specialized;
using Kaio.Core.Extension;

namespace MvcForum.Net.Bussiness
{
    public class Moderator
    {

        private NameValueCollection _values;

        private NameValueCollection Values
        {
            get
            {
                return _values ?? (_values = !string.IsNullOrWhiteSpace(AccessMask)
                                                 ? AccessMask.ToNameValueCollection('|', ':') 
                                                 : null);
            }
        }

        public string this[string key]
        {
            get { return Values != null ? Values[key] : null; }
        }

        public int Id { get; set; }
        public string UserName { get; set; }
        public string ForumName { get; set; }
        public string AccessMask { get; set; }
        public int ForumId { get; set; }
        /*public short ModerateEmailType { get; set; }*/

        #region Moderation Email Options

        public bool EmailForNewTopics { get { return Convert.ToBoolean(this["EmailForNewTopics"]); } }
        public bool EmailForNewPosts
        {
            get { return Convert.ToBoolean(this["EmailForNewPosts"]); }
        }
        public bool EmailForEditedPosts { get { return Convert.ToBoolean(this["EmailForEditedPosts"]); } }


        #endregion


        #region Post & Topic Permissions

        public bool EditTopics { get { return Convert.ToBoolean(this["EditTopics"]); } }

        public bool EditPosts { get { return Convert.ToBoolean(this["EditPosts"]); } }

        public bool DeletePosts { get { return Convert.ToBoolean(this["DeletePosts"]); } }

        public bool DeleteTopics { get { return Convert.ToBoolean(this["DeleteTopics"]); } }

        #endregion

        #region Moderation Permissions


        public bool ApproveTopics { get { return Convert.ToBoolean(this["ApproveTopics"]); } }

        public bool ApprovePosts { get { return Convert.ToBoolean(this["ApprovePosts"]); } }

        public bool QueueTopics { get { return Convert.ToBoolean(this["QueueTopics"]); } }

        public bool QueuePosts { get { return Convert.ToBoolean(this["QueuePosts"]); } }

        public bool MoveTopics { get { return Convert.ToBoolean(this["MoveTopics"]); } }

        public bool UnMoveTopics { get { return Convert.ToBoolean(this["UnMoveTopics"]); } }

        public bool LockTopics { get { return Convert.ToBoolean(this["LockTopics"]); } }

        public bool UnLockTopics { get { return Convert.ToBoolean(this["UnLockTopics"]); } }

        public bool PinTopics { get { return Convert.ToBoolean(this["PinTopics"]); } }

        public bool UnPinTopics { get { return Convert.ToBoolean(this["UnPinTopics"]); } }


        #endregion

        

    }
}
